package com.sky.controller.user;


import com.sky.constant.StatusConstant;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j

@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "C端套餐浏览接口")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;
    @Cacheable(value = "setmealCache",key = "#categoryId")
    @RequestMapping("/list")
    public Result<List<Setmeal>> list(Long categoryId){
         Setmeal setmeal=new Setmeal();
         setmeal.setCategoryId(categoryId);
         setmeal.setStatus(StatusConstant.ENABLE);
        List<Setmeal> list = setmealService.list(setmeal);
        log.info("查询的套餐：{}",list);
        return Result.success(list);

    }
}
